
#include <mockcpp/mockcpp.hpp>
#include <testngpp/testngpp.hpp>
#include "Length.h"
#include "Volume.h"

USING_MOCKCPP_NS
USING_TESTNGPP_NS

FIXTURE(Volume)
{
    TEST(should be able to check equality of same volume unit)
    {
        ASSERT_TRUE(Dimension(100, OUNCE) == Dimension(100, OUNCE));
        ASSERT_TRUE(Dimension(30, PINT) == Dimension(30, PINT));
        ASSERT_TRUE(Dimension(5, QUART) == Dimension(5, QUART));
    }

    TEST(should be able to check inequality of different volume unit)
    {
        ASSERT_TRUE(Dimension(10, OUNCE) != Dimension(10, PINT));
        ASSERT_TRUE(Dimension(25, PINT) != Dimension(25, QUART));
    }

    TEST(should be able to check inequality of differnt unit type)
    {
        ASSERT_TRUE(Dimension(1, OUNCE) != Dimension(1, FEET));
    }

    TEST(1 pint should be equal to 20 ounce)
    {
        ASSERT_EQ(Dimension(1, PINT), Dimension(20, OUNCE));
    }

    TEST(1 quart should be equal to 2 pint)
    {
        ASSERT_EQ(Dimension(1, QUART), Dimension(2, PINT));
    }
    
    TEST(20 ounce plus 1 quart should be equal to 3 pint)
    {
        ASSERT_TRUE(Dimension(20, OUNCE) + Dimension(1, QUART) == Dimension(3, PINT));
    }
    
    TEST(2 pint plus 1 ounce should be equal to 41 ounce)
    {
        ASSERT_TRUE(Dimension(2, PINT) + Dimension(1, OUNCE) == Dimension(41, OUNCE));
    }
    
    TEST(Should be able to throw exception upon addition between different unit type)
    {
        int hasException = 0;
        try
        {
            Dimension d = Dimension(1, YARD) + Dimension(1, PINT);
        }
        catch (int exception)
        {
            hasException = 1;
            ASSERT_EQ(exception, DIFFERENT_UNIT_TYPE);
        }
        ASSERT_EQ(hasException, 1);
    }
    
    TEST(Should be able to output 25 OUNCE as formatted string 1 PINT 5 OUNCE)
    {
        ASSERT_TRUE(Dimension(25, OUNCE).toString() == "1 PINT 5 OUNCE");
    }
    
    TEST(Should be able to output 61 OUNCE as formatted string 1 QUART 1 PINT 1 OUNCE)
    {
        ASSERT_TRUE(Dimension(61, OUNCE).toString() == "1 QUART 1 PINT 1 OUNCE");
    }
    
    TEST(Should be able to output 5 PINT as formatted string 2 QUART 1 PINT)
    {
        ASSERT_TRUE(Dimension(5, PINT).toString() == "2 QUART 1 PINT");
    }
    
    TEST(Should be able to output 41 OUNCE as formatted string 1 QUART 1 OUNCE)
    {
        ASSERT_TRUE(Dimension(41, OUNCE).toString() == "1 QUART 1 OUNCE");
    }
    
    TEST(Should be able to output 1 QUART as formatted string 40 OUNCE)
    {
        ASSERT_TRUE(Dimension(1, QUART).toStringInSmallestUnit() == "40 OUNCE");
    }
    
    TEST(Should be able to output 3 PINT as formatted string 60 OUNCE)
    {
        ASSERT_TRUE(Dimension(3, PINT).toStringInSmallestUnit() == "60 OUNCE");
    }
    
    TEST(Should be able to output 0 QUART as formatted string 0 OUNCE)
    {
        ASSERT_TRUE(Dimension(0, QUART).toString() == "0 OUNCE");
        ASSERT_TRUE(Dimension(0, QUART).toStringInSmallestUnit() == "0 OUNCE");
    }
};

